package ahblue.cn.tanzi.ui.person;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import ahblue.cn.tanzi.R;
import ahblue.cn.tanzi.model.user.LoginResultModel;
import ahblue.cn.tanzi.ui.MainActivity;
import ahblue.cn.tanzi.ui.base.BaseActivity;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by fengdongfei on 2018/12/1.
 */

public class InvitedActivity extends BaseActivity {
    @BindView(R.id.ivfinish)
    ImageView ivfinish;
    @BindView(R.id.etpwd)
    EditText etpwd;
    @BindView(R.id.tvlogin)
    TextView tvlogin;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_intivited_code);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.ivfinish, R.id.tvlogin})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ivfinish:
                finish();
                break;
            case R.id.tvlogin:
                if (TextUtils.isEmpty(etpwd.getText().toString())){
                    return;
                }
                LoginResultModel.setInvitedCode(this, etpwd.getText().toString(), LoginResultModel.getToken(this), new LoginResultModel.LoginStatus() {
                    @Override
                    public void conver(LoginResultModel model) {
                        startActivity(new Intent(InvitedActivity.this, MainActivity.class));
                        finish();
                    }
                });
                break;
        }
    }
}
